package media;

import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.InputStream;

import core.Const;

public class MediaUtil {
	public static Image getImage(String fileName){
		return Toolkit.getDefaultToolkit().getImage(
				MediaUtil.class.getResource("/media/" + fileName));
	}

	public static Font getFontByName(String fileName, float size) {
		String fName = "/media/" + fileName;
		Font font = null;
		try {
			InputStream is = MediaUtil.class.getResourceAsStream(fName);
			font = Font.createFont(Font.TRUETYPE_FONT, is);
			font = font.deriveFont(0, size);
		} catch (Exception ex) {
			ex.printStackTrace();
			System.err.println(fName + " not loaded.  Using default font.");
			font = Const.FONT_VALUE_DISP;
		}
		return font;
	}
}
